﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Utility
{
	public static class GizmosEX
	{
		public static void DrawCircle (Vector3 position, float radius, Vector3 normal, int segments = 16)
		{
			float d_angle = 360f / segments;
			Quaternion r_normal = Quaternion.FromToRotation (Vector3.up, normal);
			for (int i = 0; i < segments; i++)
			{
				int next = i == segments - 1 ? 0 : i + 1;

				float angle_from = d_angle * i;
				float angle_to = d_angle * next;

				Quaternion r_from = r_normal * Quaternion.Euler (0, angle_from, 0);
				Quaternion r_to = r_normal * Quaternion.Euler (0, angle_to, 0);

				Vector3 from = position + r_from * new Vector3 (0, 0, radius);
				Vector3 to = position + r_to * new Vector3 (0, 0, radius);
				Gizmos.DrawLine (from, to);
			}
		}
	}
}